{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "\n",
    "df = pd.read_csv('pdd_xinjiangxing.csv')\n",
    "# df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>web-scraper-order</th>\n",
       "      <th>web-scraper-start-url</th>\n",
       "      <th>titles</th>\n",
       "      <th>tags</th>\n",
       "      <th>prices</th>\n",
       "      <th>sales</th>\n",
       "      <th>pics-src</th>\n",
       "      <th>html_datas</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1639496865-1019</td>\n",
       "      <td>https://yangkeduo.com/search_result.html?searc...</td>\n",
       "      <td>空心山楂球山楂干甜杏干杏肉蜜饯果脯休闲零食水果干酸甜凉果鲜果</td>\n",
       "      <td>退货包运费</td>\n",
       "      <td>2.63</td>\n",
       "      <td>100000</td>\n",
       "      <td>https://img-1.pddpic.com/mms-material-img/2020...</td>\n",
       "      <td>&lt;div class=\"_28aZEDfA _21K8BYKm\"&gt;&lt;div class=\"_...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1639496865-988</td>\n",
       "      <td>https://yangkeduo.com/search_result.html?searc...</td>\n",
       "      <td>阳高杏脯山西大同特产无添加酸甜原味杏肉天然蜜饯果脯小零食杏干</td>\n",
       "      <td>退货包运费满42返3</td>\n",
       "      <td>3.4</td>\n",
       "      <td>53000</td>\n",
       "      <td>https://img-1.pddpic.com/goods/images/2020-05-...</td>\n",
       "      <td>&lt;div class=\"_28aZEDfA _21K8BYKm\"&gt;&lt;div class=\"_...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1639496865-1017</td>\n",
       "      <td>https://yangkeduo.com/search_result.html?searc...</td>\n",
       "      <td>正宗加州西梅干酸甜西梅小包装西梅休闲果干食品小吃120g/500g</td>\n",
       "      <td>退货包运费极速退款</td>\n",
       "      <td>1.45</td>\n",
       "      <td>63000</td>\n",
       "      <td>https://img-1.pddpic.com/goods/images/2020-05-...</td>\n",
       "      <td>&lt;div class=\"_28aZEDfA _21K8BYKm\"&gt;&lt;div class=\"_...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>1639496865-837</td>\n",
       "      <td>https://yangkeduo.com/search_result.html?searc...</td>\n",
       "      <td>买一罐送一罐新货大颗粒开心果500g/50g精选原味坚果休闲零食</td>\n",
       "      <td>坏了包赔</td>\n",
       "      <td>2.9</td>\n",
       "      <td>26000</td>\n",
       "      <td>https://img-1.pddpic.com/mms-material-img/2021...</td>\n",
       "      <td>&lt;div class=\"_28aZEDfA _21K8BYKm\"&gt;&lt;div class=\"_...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>1639496865-946</td>\n",
       "      <td>https://yangkeduo.com/search_result.html?searc...</td>\n",
       "      <td>2021新货东北松子手剥开口特产新鲜大颗粒红松子散装原味包邮</td>\n",
       "      <td>退货包运费</td>\n",
       "      <td>10.1</td>\n",
       "      <td>80000</td>\n",
       "      <td>https://img-1.pddpic.com/mms-material-img/2021...</td>\n",
       "      <td>&lt;div class=\"_28aZEDfA _21K8BYKm\"&gt;&lt;div class=\"_...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>495</th>\n",
       "      <td>1639496865-896</td>\n",
       "      <td>https://yangkeduo.com/search_result.html?searc...</td>\n",
       "      <td>高腰牛仔裤女加厚宽松2021年秋冬新款显瘦显高直筒老爹加绒裤子女</td>\n",
       "      <td>旗舰店退货包运费满59返3</td>\n",
       "      <td>13.1</td>\n",
       "      <td>100000</td>\n",
       "      <td>NaN</td>\n",
       "      <td>&lt;div class=\"_28aZEDfA _21K8BYKm\"&gt;&lt;div class=\"_...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>496</th>\n",
       "      <td>1639496865-607</td>\n",
       "      <td>https://yangkeduo.com/search_result.html?searc...</td>\n",
       "      <td>腾飞荣达新疆杏肉250g甘草杏无核大杏干酸甜杏零食小袋装蜜饯果干</td>\n",
       "      <td>旗舰店退货包运费极速退款</td>\n",
       "      <td>3.36</td>\n",
       "      <td>4147</td>\n",
       "      <td>https://img-1.pddpic.com/open-gw/2021-10-16/39...</td>\n",
       "      <td>&lt;div class=\"_28aZEDfA _21K8BYKm\"&gt;&lt;div class=\"_...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>497</th>\n",
       "      <td>1639496865-619</td>\n",
       "      <td>https://yangkeduo.com/search_result.html?searc...</td>\n",
       "      <td>甘草杏甘草杏肉混合口味杏干杏脯酸甜蜜饯阿梅肉新疆杏干开胃蜜杏</td>\n",
       "      <td>退货包运费极速退款第2件减3元</td>\n",
       "      <td>4.8</td>\n",
       "      <td>44000</td>\n",
       "      <td>https://img-1.pddpic.com/mms-material-img/2021...</td>\n",
       "      <td>&lt;div class=\"_28aZEDfA _21K8BYKm\"&gt;&lt;div class=\"_...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>498</th>\n",
       "      <td>1639496865-623</td>\n",
       "      <td>https://yangkeduo.com/search_result.html?searc...</td>\n",
       "      <td>新疆吊干杏无核甜酸杏干果干原味无添加杏肉干杏肉脯蜜饯孕妇零食</td>\n",
       "      <td>旗舰店立减2元退货包运费</td>\n",
       "      <td>0.9</td>\n",
       "      <td>14000</td>\n",
       "      <td>https://img-1.pddpic.com/mms-material-img/2021...</td>\n",
       "      <td>&lt;div class=\"_28aZEDfA _21K8BYKm\"&gt;&lt;div class=\"_...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>499</th>\n",
       "      <td>1639496865-1080</td>\n",
       "      <td>https://yangkeduo.com/search_result.html?searc...</td>\n",
       "      <td>新鲜奶酪酸奶疙瘩纯牛奶奶酪新疆特产游牧人干粮鲜酸奶球新鲜乳酪预售：12月22日发完</td>\n",
       "      <td>退货包运费极速退款</td>\n",
       "      <td>4</td>\n",
       "      <td>3890</td>\n",
       "      <td>NaN</td>\n",
       "      <td>&lt;div class=\"_28aZEDfA _21K8BYKm\"&gt;&lt;div class=\"_...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>497 rows × 8 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "    web-scraper-order                              web-scraper-start-url  \\\n",
       "1     1639496865-1019  https://yangkeduo.com/search_result.html?searc...   \n",
       "2      1639496865-988  https://yangkeduo.com/search_result.html?searc...   \n",
       "3     1639496865-1017  https://yangkeduo.com/search_result.html?searc...   \n",
       "4      1639496865-837  https://yangkeduo.com/search_result.html?searc...   \n",
       "5      1639496865-946  https://yangkeduo.com/search_result.html?searc...   \n",
       "..                ...                                                ...   \n",
       "495    1639496865-896  https://yangkeduo.com/search_result.html?searc...   \n",
       "496    1639496865-607  https://yangkeduo.com/search_result.html?searc...   \n",
       "497    1639496865-619  https://yangkeduo.com/search_result.html?searc...   \n",
       "498    1639496865-623  https://yangkeduo.com/search_result.html?searc...   \n",
       "499   1639496865-1080  https://yangkeduo.com/search_result.html?searc...   \n",
       "\n",
       "                                          titles             tags prices  \\\n",
       "1                 空心山楂球山楂干甜杏干杏肉蜜饯果脯休闲零食水果干酸甜凉果鲜果            退货包运费   2.63   \n",
       "2                 阳高杏脯山西大同特产无添加酸甜原味杏肉天然蜜饯果脯小零食杏干       退货包运费满42返3    3.4   \n",
       "3              正宗加州西梅干酸甜西梅小包装西梅休闲果干食品小吃120g/500g        退货包运费极速退款   1.45   \n",
       "4             买一罐送一罐新货大颗粒开心果500g/50g精选原味坚果休闲零食             坏了包赔    2.9   \n",
       "5                 2021新货东北松子手剥开口特产新鲜大颗粒红松子散装原味包邮            退货包运费   10.1   \n",
       "..                                           ...              ...    ...   \n",
       "495             高腰牛仔裤女加厚宽松2021年秋冬新款显瘦显高直筒老爹加绒裤子女    旗舰店退货包运费满59返3   13.1   \n",
       "496             腾飞荣达新疆杏肉250g甘草杏无核大杏干酸甜杏零食小袋装蜜饯果干     旗舰店退货包运费极速退款   3.36   \n",
       "497               甘草杏甘草杏肉混合口味杏干杏脯酸甜蜜饯阿梅肉新疆杏干开胃蜜杏  退货包运费极速退款第2件减3元    4.8   \n",
       "498               新疆吊干杏无核甜酸杏干果干原味无添加杏肉干杏肉脯蜜饯孕妇零食     旗舰店立减2元退货包运费    0.9   \n",
       "499  新鲜奶酪酸奶疙瘩纯牛奶奶酪新疆特产游牧人干粮鲜酸奶球新鲜乳酪预售：12月22日发完        退货包运费极速退款      4   \n",
       "\n",
       "      sales                                           pics-src  \\\n",
       "1    100000  https://img-1.pddpic.com/mms-material-img/2020...   \n",
       "2     53000  https://img-1.pddpic.com/goods/images/2020-05-...   \n",
       "3     63000  https://img-1.pddpic.com/goods/images/2020-05-...   \n",
       "4     26000  https://img-1.pddpic.com/mms-material-img/2021...   \n",
       "5     80000  https://img-1.pddpic.com/mms-material-img/2021...   \n",
       "..      ...                                                ...   \n",
       "495  100000                                                NaN   \n",
       "496    4147  https://img-1.pddpic.com/open-gw/2021-10-16/39...   \n",
       "497   44000  https://img-1.pddpic.com/mms-material-img/2021...   \n",
       "498   14000  https://img-1.pddpic.com/mms-material-img/2021...   \n",
       "499    3890                                                NaN   \n",
       "\n",
       "                                            html_datas  \n",
       "1    <div class=\"_28aZEDfA _21K8BYKm\"><div class=\"_...  \n",
       "2    <div class=\"_28aZEDfA _21K8BYKm\"><div class=\"_...  \n",
       "3    <div class=\"_28aZEDfA _21K8BYKm\"><div class=\"_...  \n",
       "4    <div class=\"_28aZEDfA _21K8BYKm\"><div class=\"_...  \n",
       "5    <div class=\"_28aZEDfA _21K8BYKm\"><div class=\"_...  \n",
       "..                                                 ...  \n",
       "495  <div class=\"_28aZEDfA _21K8BYKm\"><div class=\"_...  \n",
       "496  <div class=\"_28aZEDfA _21K8BYKm\"><div class=\"_...  \n",
       "497  <div class=\"_28aZEDfA _21K8BYKm\"><div class=\"_...  \n",
       "498  <div class=\"_28aZEDfA _21K8BYKm\"><div class=\"_...  \n",
       "499  <div class=\"_28aZEDfA _21K8BYKm\"><div class=\"_...  \n",
       "\n",
       "[497 rows x 8 columns]"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.dropna(subset=['sales'],inplace=True)\n",
    "df['prices'] = df['prices'].str.strip('券后¥')\n",
    "df['sales'] = df['sales'].str.strip('已拼').str.strip('总售').str.strip('件').str.strip('+')\n",
    "# df['sales'] = df['sales'].str.replace('万','0000')\n",
    "df['sales'] = df.apply(lambda x: str(int(float(x['sales'].replace('万',''))*10000)) if \"万\" in x['sales'] else x['sales'], axis=1)\n",
    "df[[]]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "interpreter": {
   "hash": "c3ac3f88986c03f5f4ea9b167d463bfb61b25cb597313235fabe727a0f7e0da2"
  },
  "kernelspec": {
   "display_name": "Python 3.9.5 64-bit ('base': conda)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.5"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
